package org.bitterorange.flansmodslain.interaction;

import org.bitterorange.flansmodslain.FlansModSlain;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import java.io.File;

public class MainCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
        if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
            if (!sender.hasPermission("flansmodslain.admin.reload")) {
                sender.sendMessage("操作失败。你没有权限使用此命令！");
                return true;
            }
            File pluginRoot = FlansModSlain.getPluginRoot();
            if (!pluginRoot.exists()) {
                pluginRoot.mkdir();
            }
            FlansModSlain.loadConfigurations();
            FlansModSlain.loadData();
            FlansModSlain.loadItems();
        }
        return true;
    }
}
